package cn.edu.nju.freshdelivery.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Dish entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "dish", catalog = "freshdelivery")
public class Dish implements java.io.Serializable {

	// Fields

	private Integer id;
	private Seller seller;
	private String name;
	private Double price;
	private String description;
	private String photo;
	private Integer star;
	private String catagory;
	private Set<Comment> comments = new HashSet<Comment>(0);
	private Set<Orderdetail> orderdetails = new HashSet<Orderdetail>(0);

	// Constructors

	/** default constructor */
	public Dish() {
	}

	/** minimal constructor */
	public Dish(Seller seller, String name, Double price, String description,
			Integer star, String catagory) {
		this.seller = seller;
		this.name = name;
		this.price = price;
		this.description = description;
		this.star = star;
		this.catagory = catagory;
	}

	/** full constructor */
	public Dish(Seller seller, String name, Double price, String description,
			String photo, Integer star, String catagory, Set<Comment> comments,
			Set<Orderdetail> orderdetails) {
		this.seller = seller;
		this.name = name;
		this.price = price;
		this.description = description;
		this.photo = photo;
		this.star = star;
		this.catagory = catagory;
		this.comments = comments;
		this.orderdetails = orderdetails;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sid", nullable = false)
	public Seller getSeller() {
		return this.seller;
	}

	public void setSeller(Seller seller) {
		this.seller = seller;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "price", nullable = false, precision = 22, scale = 0)
	public Double getPrice() {
		return this.price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	@Column(name = "description", nullable = false, length = 65535)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "photo", length = 65535)
	public String getPhoto() {
		return this.photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	@Column(name = "star", nullable = false)
	public Integer getStar() {
		return this.star;
	}

	public void setStar(Integer star) {
		this.star = star;
	}

	@Column(name = "catagory", nullable = false, length = 45)
	public String getCatagory() {
		return this.catagory;
	}

	public void setCatagory(String catagory) {
		this.catagory = catagory;
	}
	@Transient
//	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "dish")
	public Set<Comment> getComments() {
		return this.comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}
	@Transient
//	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "dish")
	public Set<Orderdetail> getOrderdetails() {
		return this.orderdetails;
	}

	public void setOrderdetails(Set<Orderdetail> orderdetails) {
		this.orderdetails = orderdetails;
	}

}